package cc.flyflow.biz.process.service.impl;

import cc.flyflow.biz.process.mapper.NodeMapper;
import cc.flyflow.biz.process.service.INodeService;
import lombok.extern.slf4j.Slf4j;
import org.flowable.engine.HistoryService;
import org.flowable.engine.TaskService;
import org.flowable.task.api.history.HistoricTaskInstance;
import org.flowable.task.api.history.HistoricTaskInstanceQuery;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
@Slf4j
public class INodeServiceImpl implements INodeService
{
    @Resource
    private NodeMapper nodeMapper;
    @Resource
    private TaskService taskService;
    @Resource
    private HistoryService historyService;

    public String findByProcInstId(String procInstId)
    {
        HistoricTaskInstanceQuery query = historyService.createHistoricTaskInstanceQuery()
                .processInstanceId(procInstId);
        HistoricTaskInstance historicTaskInstance = query.orderByTaskCreateTime().desc().list().get(0);
        return historicTaskInstance.getName();
    }
}
